<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/pages/common/component.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>转账管理</title>

<script language="javascript">
var oprateAction = "transferAccountAction.do";

// 删除选中的记录
function del(){
	var cbIds = $('input:checked');
	if(cbIds.length == 0){
		alert("请选择要删除的数据!");
		return ;
	}
	if(confirm('确定将选择的'+cbIds.length+'条记录删除吗?')){
		$("#method").val("delete");
		$("#transferAccountForm").submit();
	}
}

//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.form2.feeId.value) return document.form2.feeId.value;
	for(i=0;i<document.form2.feeId.length;i++)
	{
		if(document.form2.feeId[i].checked)
		{
			if(allSel=="")
				allSel=document.form2.feeId[i].value;
			else
				allSel=allSel+"`"+document.form2.feeId[i].value;
		}
	}
	return allSel;
}

//获得选中其中一个的id
function getOneItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
				allSel = document.form2.id[i].value;
				break;
		}
	}
	return allSel;
}
function selAll()
{
	$("input[name='transferAccountIds']").each(function(){
    	$(this).attr("checked",true);
    });
}
function noSelAll()
{
	$("input[name='transferAccountIds']").each(function(){
    	$(this).attr("checked",false);
    });
}
// 新增
function add(){
	window.location.href="/venus/"+oprateAction+"?method=create";
}
// 编辑
function edit(transferAccountId){
	window.location.href="/venus/"+oprateAction+"?method=edit&transferAccountId="+transferAccountId;
}

$(document).ready(function(){
	// 修改数据变色
	var updateId = '<c:out value="${updateId}"/>';
	if(updateId){
		$("#data_"+updateId).css("background","#F570A5");
		$("#data_"+updateId).attr("onMouseMove","");
		$("#data_"+updateId).attr("onMouseOut","");
	}
	
	// 新增数据变色
	var newId = '<c:out value="${newId}"/>';
	if(newId){
		$("#data_"+newId).css("background","#8080E6");
		$("#data_"+newId).attr("onMouseMove","");
		$("#data_"+newId).attr("onMouseOut","");
	}
	
	// 创建时间
	configDate("startDate", "<c:out value="${transferAccountForm.startDate}"/>", 'yy-mm-dd');
  	configDate("endDate", "<c:out value="${transferAccountForm.endDate}"/>", 'yy-mm-dd');
    // 校验主表单
    $("#transferAccountForm").validationEngine();
});

function checkTransferAccount(){
	var fromAccountId = $("#fromAccountId");
	var toAccountId = $("#toAccountId");
	if(fromAccountId.val() == toAccountId.val()){
		return "转入账户和转出账户不能相同!";
	}
}

function queryTransferAccount(){
	// 重置分页信息
	$("#curPage").val(1);
	$('#method').val('list');
	$('#transferAccountForm').submit();
}

</script>
</head>
<body leftmargin="8" topmargin="8" background='pages/desktop/skin/images/allbg.gif'>
<!--  内容列表   -->
<html:form method="post" styleId="transferAccountForm" action="transferAccountAction.do">
<input type="hidden" id="method" name="method" value=""/>

<table width='98%' border='0' cellpadding='1' cellspacing='1' bgcolor='#CBD8AC' align="center" style="margin-top:8px" background='pages/desktop/skin/images/wbg.gif'>
  <tr bgcolor='#EEF4EA'>
    <td align='left'>
    	转出账户:
    	<select name="fromAccountId" id="fromAccountId" style='width:200px;'>
    		<option value="0" ${transferAccountForm.fromAccountId==0 ? 'selected' : ''}>全部</option>
    		<c:forEach items="${lstFormAccounts}" var="fromAccount">
    			<option value="${fromAccount.accountId }" ${transferAccountForm.fromAccountId==fromAccount.accountId ? 'selected' : ''}>${fromAccount.pubUser.name }：${fromAccount.accountName }</option>
    		</c:forEach>
    	</select>
    	&nbsp;&nbsp;
    	转入账户:
    	<select name="toAccountId" id="toAccountId" style='width:200px;'>
    		<option value="0" ${transferAccountForm.toAccountId==0 ? 'selected' : ''}>全部</option>
    		<c:forEach items="${lstToAccounts}" var="toAccount">
    			<option value="${toAccount.accountId }" ${transferAccountForm.toAccountId==fromAccount.accountId ? 'selected' : ''}>${toAccount.pubUser.name }：${toAccount.accountName }</option>
    		</c:forEach>
    	</select>
    	&nbsp;&nbsp;
    	时间范围:
    	<input id="startDate" name="startDate" readonly="readonly" style='width:80px;'/>至<input id="endDate" name="endDate" readonly="readonly" style='width:80px;'/>
    	&nbsp;&nbsp;
    	金额范围:
    	<input id="minAmount" name="minAmount" class="validate[custom[number]]" style='width:60px;' value="${transferAccountForm.minAmount!=0?transferAccountForm.minAmount:''}"/>至<input id="maxAmount" name="maxAmount" class="validate[custom[number]]" style='width:60px;' value="${transferAccountForm.maxAmount!=0?transferAccountForm.maxAmount:''}"/>
    	&nbsp;&nbsp;
    	<button onclick="queryTransferAccount()">查询</button>
    </td>
  </tr>
</table>

<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7">
	<td height="24" colspan="11" background="pages/desktop/skin/images/tbg.gif">&nbsp;账户列表&nbsp;</td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
	<td width="3%"></td>
	<td width="3%">编号</td>
	<td width="12%">转出账户</td>
	<td width="12%">转入账户</td>
	<td width="8%">金额</td>
	<td width="3%">手续费</td>
	<td width="8%">转账日期</td>
	<td width="12%">备注</td>
	<td width="6%">操作</td>
</tr>
<c:forEach var="transferAccount" items="${lstTransferAccountVOs}" varStatus="i">
	<tr id="data_${transferAccount.transferAccountId }" align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FAFAF1';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
		<td><input name="transferAccountIds" type="checkbox" id="transferAccountIds" value="${transferAccount.transferAccountId }" class="np"></td>
		<td>${transferAccount.transferAccountId }</td>
		<td>${transferAccount.fromAccount.accountName }</td>
		<td>${transferAccount.toAccount.pubUser.name }：${transferAccount.toAccount.accountName }</td>
		<td>${transferAccount.amount }</td>
		<td>${transferAccount.handFee }</td>
		<td>
			<fmt:formatDate value="${transferAccount.transferDate }" pattern="yyyy年MM月dd日"/>
		</td>
		<td>${transferAccount.note }</td>
		<td><a href="#" onclick="edit('${transferAccount.transferAccountId }');">编辑</a></td>
	</tr>
</c:forEach>


<tr bgcolor="#FAFAF1">
	<td align="left" height="28" colspan="4">
		&nbsp;
		<a href="javascript:selAll()" class="coolbg">全选</a>
		<a href="javascript:noSelAll()" class="coolbg">取消</a>
		<a href="javascript:add()" class="coolbg">新增</a>
		<a href="javascript:del()" class="coolbg">&nbsp;删除&nbsp;</a>
	</td>
	<td align="right" height="28" colspan="8">
		<venus:splitPage name="objPageInfo" formId="transferAccountForm"/>
	</td>
</tr>
</table>
</html:form>
</body>
</html>